<template>
  <button 
    class="singer-button" 
    :class="{ 'is-active': active }"
    :style="{ backgroundColor: backgroundColor }"
    @click="$emit('click')"
  >
    <slot>{{ text }}</slot>
  </button>
</template>

<script setup>
defineProps({
  text: {
    type: String,
    default: '按钮'
  },
  backgroundColor: {
    type: String,
    default: 'inherit'
  },
  active: {
    type: Boolean,
    default: false
  }
})
</script>

<style scoped>
.singer-button {
  display: inline-block;
  padding: 4px 10px;
  border: none;
  border-radius: 16px;
  background-color: inherit;
  color: white;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap; /* 确保文字不换行 */
  cursor: pointer;
  transition: all 0.3s;
  min-width: auto; /* 宽度自适应内容 */
  width: auto; /* 宽度自适应内容 */
  height: 32px; /* 固定按钮高度 */
  text-align: center;
  box-sizing: border-box;
  margin: 0px;
}

.singer-button:hover {
  color: red;
  background-color: #ecf5ff;
}

.singer-button.is-active {
  background-color: red !important;
  color: #ffffff;
}
</style>